package com.example.springboot.config.healthindicator;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/10/28 22:33
 */
@Component
public class MyHealthIndicator implements HealthIndicator {
    @Override
    public Health health() {
        // 自定义的健康检查方法
        // 不健康返回
        Map<String,Object> map=new HashMap<>(10);
        map.put("msg","服务器异常");
        Health.down().withDetails(map).build();
        // 健康情况下返回
        return Health.up().build();

    }
}
